<%@page import="java.util.List"%>
<%@page import="cn.kgcnews.pojo.NewsDetail"%>
<%@page import="cn.kgcnews.pojo.PageBean"%>
<%@page import="cn.kgcnews.service.NewsService"%>
<%@page import="cn.kgcnews.service.impl.NewsServiceImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>新闻中国后台管理系统</title>
    <!-- Bootstrap -->
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../css/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../css/nprogress/nprogress.css" rel="stylesheet">
    <!-- Custom Theme Style -->
    <link href="../css/custom.min.css" rel="stylesheet">
    <style type="text/css">
     .x_content form ul {
       list-style: none;
     }
     .x_content form ul li{
       width: 350px;
       display: inline-block;
       height:40px;
       line-height: 40px;
       vertical-align: middle;
     }
     .tooltip{
     z-index:9999999999;
     }
     .dropdown-menu{
     min-width:105px;
     }
    </style>
</head>

<body class="nav-md">
	<div class="container body">
		<div class="main_container">
			<%@include file="header.jsp"%>
			<!-- page content -->
			<div class="right_col" role="main">
				<div class="row">
					<div class="col-md-12">
						<div class="x_panel">
							<div class="x_title">
								<h2>
									新闻列表维护 <i class="fa fa-user"></i><small>当前操作用户-您可以通过搜索或者其他的筛选项对用户的信息进行修改、删除等管理操作。^_^</small>
								</h2>
								<div class="clearfix"></div>
							</div>
							<div class="x_content">
								<form id="form1" method="post" action="donewslist.jsp">
								   <input type="hidden" name="pageno" value="1" />
									<ul>
										<li>
										    <%
										       /*  String queryTitle="";
										        int ntid=0;
										        if(session.getAttribute("queryTitle")!=null){
										            queryTitle=(String)session.getAttribute("queryTitle");
										        }
										        if(session.getAttribute("ntid")!=null){
										            ntid=(Integer)session.getAttribute("ntid");
										        } */
										    %>
											<div class="form-group">
												<label class="control-label col-md-3 col-sm-3 col-xs-12">新闻标题</label>
												<div class="col-md-6 col-sm-6 col-xs-12">
													<input name="queryTitle" type="text"
														class="form-control col-md-7 col-xs-12" value="${queryTitle}">
												</div>
											</div>
										</li>
										<li>
											<div class="form-group">
												<label class="control-label col-md-3 col-sm-3 col-xs-12">新闻类型</label>
												<div class="col-md-6 col-sm-6 col-xs-12">
													<select  id="ntid" name="ntid" class="form-control col-md-7 col-xs-12">
											        <option value="0">--请选择类型--</option>
											        <option value="1" <c:if test='${ntid eq 1}'>selected</c:if>>--国内--</option>
											        <option value="2" <c:if test='${ntid eq 2}'>selected</c:if>>--国际--</option>
										            </select>
												</div>
											</div>
										</li>						
										<li><button type="submit" class="btn btn-primary">
												查 &nbsp;&nbsp;&nbsp;&nbsp;询</button></li>
									</ul>
								</form>
							</div>
						</div>
					</div>
					<div class="col-md-12 col-sm-12 col-xs-12">
						<div class="x_panel">
							<div class="x_content">
								<p class="text-muted font-13 m-b-30"></p>
								<div id="datatable-responsive_wrapper"
									class="dataTables_wrapper form-inline dt-bootstrap no-footer">
									<div class="row">
										<div class="col-sm-12">
											<a href="newsadd.jsp" class="btn btn-success btn-sm" target="_blank">新增新闻</a>
											<table id="datatable-responsive"
												class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
												 role="grid"
												aria-describedby="datatable-responsive_info"
												style="width: 100%;">
												<thead>
													<tr role="row">
														<th class="sorting_asc" tabindex="0"
															aria-controls="datatable-responsive" rowspan="1"
															colspan="1"
															aria-label="First name: activate to sort column descending"
															aria-sort="ascending">新闻标题</th>																							
														<th class="sorting" tabindex="0"
															aria-controls="datatable-responsive" rowspan="1"
															colspan="1"
															aria-label="Last name: activate to sort column ascending">
															作者</th>
														<th class="sorting" tabindex="0"
															aria-controls="datatable-responsive" rowspan="1"
															colspan="1"
															aria-label="Last name: activate to sort column ascending">
															发布日期</th>
														<th class="sorting" tabindex="0"
															aria-controls="datatable-responsive" rowspan="1"
															colspan="1" style="width: 124px;"
															aria-label="Last name: activate to sort column ascending">
															操作</th>
													</tr>
												</thead>
												<tbody>	
												       <c:forEach items="${bean.list }" var="news">
												       				
														<tr role="row" class="odd">
															<td tabindex="0" class="sorting_1"><a href="newsReadServlet?action=newsread&newsid=${news.id}" target="_blank">${news.title}</a></td>
															<td>${news.author}</td>	
															<td>${news.createDate}</td>												
															<td>
																<div class="btn-group">
																	<button type="button" class="btn btn-danger">点击操作</button>
																	<button type="button"
																		class="btn btn-danger dropdown-toggle"
																		data-toggle="dropdown" aria-expanded="false">
																		<span class="caret"></span>
																	</button>
																	<ul class="dropdown-menu" role="menu">															
																		<li><a class="modifyVersion" href=""																			
																			data-toggle="tooltip" data-placement="top" title=""
																			data-original-title="修改新闻的基本信息">修改新闻</a></li>
																		<li><a class="deleteApp" onclick="return delNews(${news.id})"
																			data-toggle="tooltip" data-placement="top" title=""
																			data-original-title="删除新闻的基本信息">删除新闻</a></li>
																	</ul>
																</div>
															</td>
														</tr>
														</c:forEach>
												</tbody>
											</table>
										</div>
									</div>
									<div class="row">
										<div class="col-sm-5 col-md-5">
											<div class="dataTables_info" id="datatable-responsive_info"
												role="status" aria-live="polite">共${bean.totalCount }条记录${bean.currPageNo }/${bean.totalPageCount }页</div>
										</div>
										<div class="col-sm-7 col-md-7">
											<div class="dataTables_paginate paging_simple_numbers"
												id="datatable-responsive_paginate">
												<ul class="pagination">
														<li class="paginate_button previous"><a
															href="SerachNews?pageno=1&queryTitle=${queryTitle}&ntid=${ntid}"
															aria-controls="datatable-responsive" data-dt-idx="0"
															tabindex="0">首页</a></li>
														<li class="paginate_button"><a
															href="SerachNews?pageno=${bean.currPageNo-1 }&queryTitle=${queryTitle}&ntid=${ntid}"
															aria-controls="datatable-responsive" data-dt-idx="1"
															tabindex="0">上一页</a></li>									
														<li class="paginate_button"><a
															href="SerachNews?pageno=${bean.currPageNo+1 }&queryTitle=${queryTitle}&ntid=${ntid}"
															aria-controls="datatable-responsive" data-dt-idx="1"
															tabindex="0">下一页</a></li>
														<li class="paginate_button next"><a
															href="SerachNews?pageno=${bean.totalCount }&queryTitle=${queryTitle}&ntid=${ntid}"
															aria-controls="datatable-responsive" data-dt-idx="7"
															tabindex="0">最后一页</a></li>
														<li ><input size="5" type="text" id="inputPage" /><button type="button" onclick="jump_to(document.getElementById('inputPage').value)">GO</button></li>
												</ul>
												<%-- <input type="hidden" id="totalPageCount" value="<%=totalPageCount %>" /> --%>
											</div>
										</div>
									</div>
								</div>

							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- /page content -->

		<!-- footer content -->
		<footer>
			<div class="pull-right">&copy;明晟科技</div>
			<div class="clearfix"></div>
		</footer>
		<!-- /footer content -->
	</div>

	<!-- jQuery -->
	<script src="../js/jquery-1.12.4.js"></script>
	<!-- Bootstrap -->
	<script src="../js/bootstrap.min.js"></script>
	<!-- FastClick -->
	<script src="../js/fastclick.js"></script>
	<!-- NProgress -->
	<script src="../css/nprogress/nprogress.js"></script>

	<!-- Custom Theme Scripts -->
	<script src="../js/custom.min.js"></script>
	<script type="text/javascript">
	   function delNews(nid){
		   var flag=window.confirm("确认要删除吗？");
		   if(flag){
			   //进行删除
			   window.location.href="newsReadServlet?action=del&niddd="+nid;
			   return true;
		   }
		   return false;
	   }
	   function page_nav(num){
	    var frm=document.forms[0];
		frm.pageno.value = num;
		frm.submit();
		}
	   function jump_to(num){
	   var regexp=/^[1-9]\d*$/;
	   var totalPageCount = document.getElementById("totalPageCount").value;
	   if(!regexp.test(num)){
		alert("请输入大于0的正整数！");
		return false;
		}else if((num-totalPageCount) > 0){
		alert("请输入小于总页数的页码");
		return false;
		}
		else{
		  page_nav(num);
	    }
       }
	</script>
</body>
</html>